package com.wn.common.pojo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.*;
import java.util.Date;
import java.util.List;


@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "User ", description = "用户实体类")
public class User {
    @ApiModelProperty(example = "1")
    private Integer userId;

    @NotBlank
    @ApiModelProperty(name="userAccount",value="用户账号",example = "tom")
    @Size(min=3,max=10,message = "用户账号长度在3-10个字符之间！")
    private String userAccount;


    @Pattern(regexp = "^\\w{6}$",message = "密码由六位大小写字母、数字及下划线组成！")
    @ApiModelProperty(name="userPassword",value="用户密码",example = "123456")
    private String userPassword;

    @Pattern(regexp = "^1[345678][0-9]{9}$",message = "手机号格式错误")
    @ApiModelProperty(name="userPhone",value="用户联系方式",example = "13512341234")
    private String userPhone;

    @Email(message = "邮箱格式错误！")
    @ApiModelProperty(name="userEmail",value="用户邮箱",example = "@qq.com")
    private String userEmail;

    @ApiModelProperty(name="userIDcard",value="用户身份证号")
    @Pattern(regexp = "^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$",message = "身份证格式错误！")
    private String userIdcard;

    @ApiModelProperty(name="userName",value="用户真实姓名",example = "tom")
    private String userName;

    @ApiModelProperty(name="userGender",value="用户性别",example = "保密")
    private String userGender;

    @ApiModelProperty(name="userPhotoWithIdcard",value="携带身份证的照片",example = "#")
    private String userPhotoWithIdcard;

    @ApiModelProperty(name="userAvatar",value="用户自定义头像",example = "#")
    private String userAvatar;

    @ApiModelProperty(hidden = true)
    private Integer createUserId;

    @ApiModelProperty(hidden = true)
    private Date createTime;

    @ApiModelProperty(hidden = true)
    private Integer updateUserId;

    @ApiModelProperty(hidden = true)
    private Date updateTime;

    @ApiModelProperty(name="userStatus",value="用户状态，1-未启用 0-已启用",example = "0")
    private String userStatus;
    @ApiModelProperty(hidden = true)
    private Role role;
    @ApiModelProperty(hidden = true)
    private Traveller traveller;
    @ApiModelProperty(hidden = true)

    private Date earliestCreateTime;

    private Date latestCreateTime;

    private Date earliestUpdateTime;

    private Date latestUpdateTime;


    private Integer userIsDeleted;
    @ApiModelProperty(name="roleSign",value="角色权限",example = "super_admin")
    @NotBlank(message = "请设置用户权限！")
    private String roleSign;

    private List<Role> roleList;

    public User(Integer userId,String userAccount,String roleSign,String userEmail) {
        this.userId = userId;
        this.userAccount = userAccount;
        this.roleSign = roleSign;
        this.userEmail = userEmail;

    }

    public User(Integer userId, @NotBlank @Size(min = 3, max = 10, message = "用户账号长度在3-10个字符之间！") String userAccount, @Pattern(regexp = "^\\w{6}$", message = "密码由六位大小写字母、数字及下划线组成！") String userPassword, @Pattern(regexp = "^1[345678][0-9]{9}$", message = "手机号格式错误") String userPhone, @Email(message = "邮箱格式错误！") String userEmail, @Pattern(regexp = "^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$", message = "身份证格式错误！") String userIdcard, String userName, String userGender, String userPhotoWithIdcard, String userAvatar, Integer createUserId, Date createTime, Integer updateUserId, Date updateTime, String userStatus, Integer userIsDeleted, @NotBlank(message = "请设置用户权限！") String roleSign) {
        this.userId = userId;
        this.userAccount = userAccount;
        this.userPassword = userPassword;
        this.userPhone = userPhone;
        this.userEmail = userEmail;
        this.userIdcard = userIdcard;
        this.userName = userName;
        this.userGender = userGender;
        this.userPhotoWithIdcard = userPhotoWithIdcard;
        this.userAvatar = userAvatar;
        this.createUserId = createUserId;
        this.createTime = createTime;
        this.updateUserId = updateUserId;
        this.updateTime = updateTime;
        this.userStatus = userStatus;
        this.userIsDeleted = userIsDeleted;
        this.roleSign = roleSign;
    }
    public User(Integer userId, @NotEmpty @NotNull String userAccount) {
        this.userId = userId;
        this.userAccount = userAccount;
    }
}
